package org.jeecg.modules.overrides.basic.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.basic.customer.controller.BasicCustomerController;
import org.jeecg.modules.basic.customer.entity.BasicCustomer;
import org.jeecg.modules.basic.customer.service.IBasicCustomerService;
import org.jeecg.modules.overrides.basic.service.IBasicCustomerOverrideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "客户信息表")
@RestController
@RequestMapping("/customer2")
@Slf4j
public class BasicCustomerOverrideController {

    @Autowired
    private IBasicCustomerOverrideService basicCustomerService;

    @ApiOperation(value = "客户信息表-分页列表查询22", notes = "客户信息表-分页列表查询22")
    @GetMapping(value = "/list")
    public Result<IPage<BasicCustomer>> queryPageList(BasicCustomer basicCustomer,
                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                      HttpServletRequest req) {
        QueryWrapper<BasicCustomer> queryWrapper = QueryGenerator.initQueryWrapper(basicCustomer, req.getParameterMap());
        Page<BasicCustomer> page = new Page<BasicCustomer>(pageNo, pageSize);
        IPage<BasicCustomer> pageList = basicCustomerService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
}
